#include <stdio.h>
#include <stdlib.h>
#include "BTreeMap.h"
//#include "../imu_track/complementary_filter.h"

// 定义 CameraIdentifier 结构体
typedef struct {
    int id; // 假设 CameraIdentifier 有一个整数 id 字段
} CameraIdentifier;

typedef struct {
    double timestamp_ms;
    double gyro[3];
    double accl[3];
    double magn[3];
} IMUData;

typedef struct {
    char* imu_orientation;//imu朝向字符串，即界面右下角的 ’XYZ‘,'X' => inp[0], 'x' => -inp[0],'Y' => inp[1], 'y' => -inp[1],'Z' => inp[2], 'z' => -inp[2],
    IMUData* raw_imu;
    size_t raw_imu_len;
    BTreeMap* quaternions;
    BTreeMap* gravity_vectors;
    BTreeMap* image_orientations;
    char* detected_source;
    double frame_readout_time;
    double frame_rate;
    char* camera_identifier;
    char* lens_profile;
    BTreeMap* lens_positions;
    int has_accurate_timestamps;
    char* additional_data;
    double* per_frame_time_offsets;
    size_t per_frame_data_len;
} FileMetadata;

// 定义 GyroSource 结构体
typedef struct {
    double duration_ms;
    IMUData* raw_imu;
    size_t raw_imu_len;
    char* imu_orientation;
    double imu_rotation_angles[3];
    Quaternion imu_rotation;
    double acc_rotation_angles[3];
    Quaternion acc_rotation;
    double imu_lpf;
    double gyro_bias[3];
    size_t integration_method;
    BTreeMap* quaternions;
    BTreeMap* smoothed_quaternions;
    BTreeMap* org_smoothed_quaternions;
    bool use_gravity_vectors;
    int32_t horizon_lock_integration_method;
    double max_angles[3];
    char* smoothing_status;
    bool prevent_recompute;
    FileMetadata* file_metadata;
    char* file_path;
} GyroSource;


// 初始化全零 IMUData 数组的函数
IMUData* init_imu_data(size_t raw_imu_len);

// 初始化有初值 IMUData
IMUData* init_imu_data(double timestamp_ms, double gyro[3], double accl[3], double magn[3]);

// 释放imu data
void free_imu_data(IMUData* imu_data);

// 初始化 FileMetadata
FileMetadata* init_file_metadata();

// 释放 FileMetadata 内存
void free_file_metadata(FileMetadata* metadata);

// 初始化 GyroSource
GyroSource* init_gyro_source();

// 释放 GyroSource 内存
void free_gyro_source(GyroSource* gyro_source);
